﻿using System;

namespace PacketRush.Core
{
    public partial class NetServer
    {
        /// <summary>
        /// Occurs when a client connects.
        /// </summary>
        public event EventHandler<NetEventArgs> Connected;
        /// <summary>
        /// Raises the <see cref="PacketRush.Core.NetServer.Connected"/> event.
        /// </summary>
        /// <param name="netConnectionId">The id of the connection.</param>
        protected void OnConnected(int netConnectionId)
        {
            if (Connected != null)
            {
                Connected(this, new NetEventArgs(netConnectionId));
            }
        }

        /// <summary>
        /// Occurs when a client disconnects.
        /// </summary>
        public event EventHandler<NetEventArgs> Disconnected;

        /// <summary>
        /// Raises the <see cref="PacketRush.Core.NetServer.Disconnected"/> event.
        /// </summary>
        /// <param name="netConnectionId">The id of the connection.</param>
        protected void OnDisconnected(int netConnectionId)
        {
            if (Disconnected != null)
            {
                Disconnected(this, new NetEventArgs(netConnectionId));
            }
        }

        /// <summary>
        /// Occurs before an <see cref="PacketRush.Core.NetServer.Update"/>
        /// </summary>
        public event EventHandler BeforeUpdate;

        /// <summary>
        /// Raises the <see cref="PacketRush.Core.NetServer.BeforeUpdate"/> event.
        /// </summary>
        protected void OnBeforeUpdate()
        {
            if (BeforeUpdate != null)
            {
                BeforeUpdate(null, null);
            }
        }

        /// <summary>
        /// Occurs after an <see cref="PacketRush.Core.NetServer.Update"/>
        /// </summary>
        public event EventHandler AfterUpdate;

        /// <summary>
        /// Raises the <see cref="PacketRush.Core.NetServer.AfterUpdate"/> event.
        /// </summary>
        protected void OnAfterUpdate()
        {
            if (AfterUpdate != null)
            {
                AfterUpdate(null, null);
            }
        }
    }
}
